<!-- file: app/views/fichiers/ajouter_videos.ctp -->

<div>

<h2 id="EV">Enregistrer une Video</h2>
<br/>
<FIELDSET id="cadrevi">
<?php
 $id_admin=$_SESSION['Auth']['admin']['id'];
//foreach ($category as $category):
//    $tipo=$category['Category']['nom'];
//    $idfi=$category['Category']['id'];
//    $opt[$idfi]=$tipo;
//endforeach;
echo $form->create('Fichier',array('action'=>'ajouter_videos','type'=>'file','onsubmit'=>'return revisar()'));
echo "<fieldset><legend>Video .OGV</legend>";
echo $form->file('non_fichier');
echo "</fieldset>";
echo "<br>";
echo "<fieldset><legend>Video .MP4</legend>";
echo $form->file('non_fichier2');
echo "</fieldset>";
echo "<br>";
echo "<p><font size='2'>Selectionnez votre categorie</font></p>";
//echo $this->Form->select('categorie_id',$opt);
echo $form->input('titre',array('type'=>'text',"class"=>'input_titlev'));
echo $form->input('description',array('label'=>'Description'));
echo $form->input('conseil', array('label'=>'Conseil')) ;
echo $form->input('admin_id', array('type'=>'hidden','value'=>$id_admin)) ;
echo $form->input('typefi', array('type'=>'hidden','value'=>'video')) ;
echo '<fieldset id="categories"> <legend>Categories</legend>';
$idc=0;
foreach ($category as $category):

    $tipo=$category['Category']['nom'];
    $idfi=$category['Category']['id'];
    $opt[$idfi]=$tipo;
    echo '<input type="checkbox" id="'.$idfi.'" name="Category['.$tipo.']" value="'.$idfi.'"/><label for="'.$idfi.'">'.$tipo.'</label><br/>';
//    echo $form->input('Category.'.$idc.'.'.$tipo.'',array('type'=>'checkbox','value' => $idfi,'label'=>$tipo,'hiddenField' => false));
endforeach;

echo '</fieldset>';
        echo "<p> <font size='2'>Choisir une image de reference pour cet enregistrement video</font><p>";

echo $form->file('image');


        ?>


        <?php
        //echo"<input type=\"text\" name=\"temp\" id=\"temp\" value=\"\">";

        echo $form->end(__('Submit', true));
        ?>
    </FIELDSET>

</div>

<script>
    function revisar(){
        var obj=document.getElementById('FichierNonFichier');
        var obj2=document.getElementById('FichierNonFichier2');
        var obj3=document.getElementById('FichierImage');
        if(!obj.value.match(/\.(OGV)$/i)){
            alert('Error avec Video OGV');
            return false;
        }else if(!obj2.value.match(/\.(MP4)$/i)){
            alert('Error avec Video MP4');
            return false;
        }else if(!obj3.value.match(/\.(BMP|GIF|JPG|PNG)$/i)){
             alert("Error avec l'Image");
            return false;
        }

    }
   
tinyMCE.init({
   mode : "textareas",
    language : 'fr'   //(n.b. no trailing comma, this will be critical as you experiment later)


});
</script>
